using System;
using System.Collections.Generic;
using System.Text;
using Shc.Sql;
using Shc.Json;
namespace CLZ.Data
{
	public static class TableCity
	{
		public const string Table = "City";
		public const string CityID = "CityID";
		public const string ProvinceID = "ProvinceID";
		public const string CityName = "CityName";
	}
	
	[Serializable]
	public class BaseCity
		: IDbSessionEntity, IJsonClass
	{
		int m_CityID;
		/// <summary>
        /// 城市表ID
        /// </summary>
        public int CityID
        {
            get { return m_CityID; }
            set { m_CityID = value; }
        }
		
		int m_ProvinceID;
		/// <summary>
        /// 省份ID
        /// </summary>
        public int ProvinceID
        {
            get { return m_ProvinceID; }
            set { m_ProvinceID = value; }
        }
		
		string m_CityName;
		/// <summary>
        /// 城市名称
        /// </summary>
        public string CityName
        {
            get { return m_CityName; }
            set { m_CityName = value; }
        }
		
		
		#region IDbSessionEntity Members
		public void ReadDBData(RowDataReader reader)
        {
            m_CityID = reader[TableCity.CityID];
            m_ProvinceID = reader[TableCity.ProvinceID];
            m_CityName = reader[TableCity.CityName];
        }
		
		public void WriteDBData(RowDataWriter writer)
        {
            writer.SetPrimaryKey(TableCity.CityID, PrimaryKeyType.Identity, CityID);
			writer[TableCity.ProvinceID] = ProvinceID;
			writer[TableCity.CityName] = CityName;
        }

        public void SetIdentityAfterInsert(DBObject idd)
        {
            m_CityID = idd;
        }
		
		public string TableName
        {
            get { return TableCity.Table; }
        }
		#endregion
		
		#region IJsonClass Members

        public void JsonDeSerializeObj(JsonHashTable hashToRead)
        {
             m_CityID = hashToRead["CityID"];
			 
             m_ProvinceID = hashToRead["ProvinceID"];
			 
             m_CityName = hashToRead["CityName"];
			 
        }

        public void JsonSerializeObj(JsonHashTable hashToFill)
        {
            hashToFill["CityID"] = CityID;
			 
            hashToFill["ProvinceID"] = ProvinceID;
			 
            hashToFill["CityName"] = CityName;
			 
        }

        #endregion
		
	}
}
